package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.ModuleQuery;
import com.gec.zhs.entity.po.Module;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.ModuleService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 功能模块表 Controller
 */
@RestController("moduleController")
@RequestMapping("/module")
public class ModuleController extends ABaseController{

	@Resource
	private ModuleService moduleService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ModuleQuery query){
		return getSuccessResponseVO(moduleService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Module bean) {
		moduleService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Module> listBean) {
		moduleService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Module> listBean) {
		moduleService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getModuleById")
	public ResponseVO getModuleById(String id) {
		return getSuccessResponseVO(moduleService.getModuleById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateModuleById")
	public ResponseVO updateModuleById(Module bean,String id) {
		moduleService.updateModuleById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteModuleById")
	public ResponseVO deleteModuleById(String id) {
		moduleService.deleteModuleById(id);
		return getSuccessResponseVO(null);
	}
}